import java.lang.reflect.Array;
import java.util.Arrays;

class Alg<T extends Comparable<T>>{
    public T findMaxVal(T[]arry){
        T number=arry[0];
        for (int i = 0; i < arry.length; i++) {
            if(arry[i].compareTo(number)>0){
                number=arry[i];
            }
        }
        return number;
    }
}
class Alg1{
    public static <T extends Comparable<T>> T findMaxVal(T[]arry){
        T number=arry[0];
        for (int i = 0; i < arry.length; i++) {
            if(arry[i].compareTo(number)>0){
                number=arry[i];
            }
        }
        return number;
    }
}
class Alg2{
    public <T extends Comparable<T>> T findMaxVal(T[]arry){
        T number=arry[0];
        for (int i = 0; i < arry.length; i++) {
            if(arry[i].compareTo(number)>0){
                number=arry[i];
            }
        }
        return number;
    }
}
class Test1<T extends Number>{
    public void fun(T tmp){
        System.out.println(tmp);
    }
}
public class Test {
    public static void main(String[] args) {
        Test1<Integer>test1=new Test1<>();
        test1.fun(10);
    }
    public static void main3(String[] args) {
        Integer[] arr=new Integer[]{1,8,10,25};
        System.out.println(Alg1.findMaxVal(arr));
        Alg2 alg2=new Alg2();
        System.out.println(alg2.findMaxVal(arr));
    }
    public static void main2(String[] args) {
        Alg<Integer>alg=new Alg<Integer>();
        Integer[]arry=new Integer[]{5,1,9,10};
        System.out.println(alg.findMaxVal(arry));
    }
    public static void main1(String[] args) {
        MyArray<Integer> myArray=new MyArray<>();
        myArray.setArr(0,10);
        //Integer[] arr=myArray.fun();
        MyArray2<Integer>myArray2=new MyArray2<>(Integer.class,10);
        myArray2.setVal(0,10);
        Integer[]arr=myArray2.getArray();
        System.out.println(Arrays.toString(arr));
    }
}
class MyArray2<T> {
    T[]array;
    public MyArray2(Class<T> clazz, int capacity) {
        array = (T[])Array.newInstance(clazz, capacity);
    }
    public T getPos(int pos) {
        return this.array[pos];
    }
    public void setVal(int pos,T val) {
        this.array[pos] = val;
    }
    public T[] getArray() {
        return array;
    }

}

class MyArray<T>{
    T[]arr=(T[])new Object[10];
    //擦除机制

    public void setArr(int post,T tmp){
        arr[post]=tmp;
    }
    public T getArr(int post){
        return arr[post];
    }
    public T[] fun(){
        return arr;
    }


}

